import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
 * Created with IntelliJ IDEA.
 * User: admin
 * Date: 17.03.14
 * Time: 21:32
 * To change this template use File | Settings | File Templates.
 */
public class googletest {
    @Test
    public void test ()throws InterruptedException {
        WebDriver driver = new FirefoxDriver()       ;
        driver.get("http://www.ukr.net/")   ;
        Thread.sleep(3000);
        String parentHandle = driver.getWindowHandle(); // get the current window handle
        driver.findElement(By.linkText("Booking")).click();

        Thread.sleep(5000);

        for (String winHandle : driver.getWindowHandles()) {
            driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
        }



        driver.findElement(By.id("aff_cobrand")).click();
        Thread.sleep(5000);
        for (String winHandle : driver.getWindowHandles()) {
            driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
        }

        driver.findElement(By.xpath("//*[@id=\"right-top\"]/section/div[2]/div/div/div[1]/a/img")).click();

        Thread.sleep(5000);
        for (String winHandle : driver.getWindowHandles()) {
            driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
        }


        WebElement sellcar = driver.findElement(By.linkText("Продать авто"));
        Assert.assertEquals(true, sellcar.isDisplayed());


        Thread.sleep(5000);
        driver.close(); // close newly opened window when done with it
        driver.switchTo().window(parentHandle); // switch back to the original window


        /*
        Thread.sleep(5000);
        driver.findElement(By.className("tmb")).click();

        Thread.sleep(5000);

*/


        driver.quit();

    }




}